//注册
const { db, mongoose } = require("../utils/mongooseUtil");

const positionSchema = {
    userName: { type: String, require },
    password: { type: String, require },
    nickName: { type: String, require }
}

const UsersModel = mongoose.model("users", positionSchema);

const save = (data) => {
    //得到从前端传送过来的用户名和密码
    const userData = new UsersModel(data)
    return userData.save(data).then(result => {
        return result
    }).catch(err => {
        return false
    })

}

const find = (query) => {
    return UsersModel.find(query).then(result => {
        return result
    }).catch(err => {
        return false
    })
}

module.exports = {
    save,
    find
}